package com.wtz.temptest;

import java.sql.Timestamp;

public class TempDemoSeven {
    public static FileSystem getFileSystem() throws Exception {
        Configuration conf = new Configuration();
        FileSystem fileSystem = FileSystem.get(conf);
        return fileSystem;
    }

    public static void readFile(String filename) throws Exception {
        //get filesystem
        FileSystem fileSystem = getFileSystem();
        //String filename = "/user/beifeng/mapreduce/input/word";
        //read path
        //String name = filename;
        Path readPath = new Path(filename);
        //open file
        FSDataInputStream inStream = fileSystem.open(readPath);

        //
        try {
            IOUtils.copyBytes(inStream, System.out, 4096, false);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            //close Stream
            IOUtils.closeStream(inStream);
        }
    }


    public static void main(String[] args) throws Exception {

        String filename = "/user/beifeng/mapreduce/input/word";
        readFile(filename);

    }
}